//index.js
//获取应用实例

var dateTimePicker = require('../../utils/dateTimePicker.js');

const app = getApp()

Page({
  data: {
    dateTimeArray1: null,
    dateTime1: null,
    startYear: null,
    endYear: null,
    one1: 0,
    one2: 0,
    one3: 0,
    one4: 0,
    two1: 0,
    two2: 0,
    two3: 0,
    three1: 0,
    three2: 0,
    three3: 0,
  },
  onShow: function () {
    var that = this
    wx.request({
      url: "http://127.0.0.1:8889/wx",
      method: 'GET',
      dataType: 'json',
      success: function (res) {

      },
      fail: function (res) {
        wx.showToast({
          title: '数据获取错误',
          icon: "none",
          duration: 1500
        })
        that.setData({
          one1: 0,
          one2: 0,
          one3: 0,
          one4: 0,
          two1: 0,
          two2: 0,
          two3: 0,
          three1: 0,
          three2: 0,
          three3: 0,
        })
      }
    })
  },
  updateQ:function(){
    wx.showToast({
      title: '正在开发中',
      icon:"none",
      duration:1500
    })
  },
  onLoad: function () {
    let that = this;

    // 获取完整的年月日 时分秒，以及默认显示的数组
    var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
    var obj1 = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
    // 精确到分的处理，将数组的秒去掉
    //var lastArray = obj1.dateTimeArray.pop();
    //var lastTime = obj1.dateTime.pop();

    this.setData({
      dateTimeArray1: obj1.dateTimeArray,
      dateTime1: obj1.dateTime
    });
  },
  // 选择日期时间
  changeDateTime1(e) {
    this.setData({
      dateTime1: e.detail.value
    });
  },
  changeDateTimeColumn1(e) {
    var arr = this.data.dateTime1,
      dateArr = this.data.dateTimeArray1;

    arr[e.detail.column] = e.detail.value;
    dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]);

    this.setData({
      dateTimeArray1: dateArr,
      dateTime1: arr

    });
  },
  getUserInfo: function (e) {
  },

})
